package com.oss.controller.oss;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.oss.common.BaseResponse;
import com.oss.dto.oss.positionmanage.*;
import com.oss.entity.oss.PositionManage;
import com.oss.service.oss.PositionManageService;
import com.oss.vo.oss.position.PositionManageSummaryVO;
import com.oss.vo.oss.position.PositionManageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * 持仓管理
 */
@RestController
@RequestMapping("/positionManage")
public class PositionManageController {
    @Autowired
    private PositionManageService positionManageService;

    @PostMapping("/selectByPage")
    public BaseResponse<IPage<PositionManageVO>> selectByPage(@RequestBody @Valid PageDto dto){
        return BaseResponse.success(positionManageService.selectByPage(dto));
    }
    // 持仓汇总
    @PostMapping("/positionSummary")
    public BaseResponse<List<PositionManageVO>> positionSummary(@RequestBody @Valid CountDto dto){
        return BaseResponse.success(positionManageService.positionSummary(dto));
    }
    // 持仓管理统计
    @PostMapping("/countByList")
    public BaseResponse<List<PositionManageVO>> countByList(@RequestBody @Valid CountDto dto){
        return BaseResponse.success(positionManageService.countByList(dto));
    }
    @PostMapping("/getByID")
    public BaseResponse<PositionManage> getByID(@RequestBody @Valid GetByIDDto dto){
        return BaseResponse.success(positionManageService.getById(dto.getId()));
    }
    @PostMapping("/add")
    public BaseResponse<String> add(@RequestBody @Valid AddDto dto){
        return BaseResponse.success(positionManageService.add(dto));
    }
    @PostMapping("/update")
    public BaseResponse<String> updateData(@RequestBody @Valid UpdateDto dto){
        return BaseResponse.success(positionManageService.updateData(dto));
    }
    @PostMapping("/delete")
    public BaseResponse<String> delete(@RequestBody @Valid DeleteDto dto){
        return BaseResponse.success(positionManageService.delete(dto));
    }
    @PostMapping("/import")
    public BaseResponse<String> importData(@RequestBody @Valid ImportDto dto){
        return BaseResponse.success(positionManageService.importData(dto));
    }
}